﻿@using MalkiSumWeb.Controllers;
@model MalkiSumWeb.Models.File
@{
    MalkiSumWeb.Models.SumrizDBEntities db = new MalkiSumWeb.Models.SumrizDBEntities();

    var Fields = db.Files.Where(f => f.IsDeleted == false &&
        f.MemberActivities.Where(m => m.FileID == f.ID
            && m.MemberID == MainController.myUserID)
            .OrderByDescending(d => d.ID).FirstOrDefault().ActionTypeID == 15
            ).Select(x => x.FieldID).Distinct().ToList();
}
@{
    ViewBag.Title = "My Favourites";
    Layout = "~/Views/Shared/_LayoutUser.cshtml";
}
@Html.Partial("_LogOnSideBar")
<div class="col-lg-10">
    <h2>
        My Favourites</h2>
    @foreach (int x in Fields)
    {
        @Html.Action("FieldView", "Files", new { cat = x, q = "", Favourites = true });
    }
    <br style="clear: both;" />
    @(Html.Telerik().Grid<MalkiSumWeb.Models.File>()
        .Name("Grid")
            .DataKeys(keys =>
            {
                keys.Add(p => p.ID);
            })
        .Columns(columns =>
        {
            columns.Bound(o => o.ID).Width(100);
            columns.Bound(o => o.Name).Width(200);
            columns.Bound(o => o.LikeCount);
            columns.Bound(o => o.ShareCount);
            columns.Bound(o => o.ReportCount);
            columns.Command(commands =>
            {
                commands.Delete();
            });
        })
            .DataBinding(dataBinding => dataBinding.Ajax()
                .Select("_MyFavourites", "Files")
                .Delete("_RemoveFavourites", "Files"))
        .Pageable()
        .Sortable()
        .Scrollable()
        .Groupable()
        .Filterable()
)
</div>
